<template>
  <div class="num">
    <div class="prd-number prd-select">
      {{$t('product.number')}}
      <span @click="minus">-</span>
      <div class="prd-num">
        <input type="tel"
               v-model="num"
               @change="changeNum">
      </div>
      <span @click="add">+</span>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      num: 1,
    }
  },
  props: {
    numbers: {
      type: Number,
      default: 1,
    },
  },
  methods: {
    add() {
      let _num
      _num = ++this.num
      this.$emit('changeNumber', Number(_num))
    },
    minus() {
      let _num
      this.num > 1 ? (_num = --this.num) : (_num = 1)
      this.$emit('changeNumber', Number(_num))
    },
    changeNum() {
      this.$emit('changeNumber', Number(this.num))
    },
  },
  watch: {},
}
</script>

<style lang="scss">
@import '~@/theme/mixin.scss';
.prd {
  &-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }
  &-num {
    display: inline-block;
    width: 30px;
    text-align: center;
    input {
      width: 100%;
      border: 0;
      text-align: center;
    }
  }
  &-number {
    color: #3e4651;
    font-size: 14px;
    span {
      display: inline-block;
      width: 18px;
      height: 18px;
      line-height: 16px;
      text-align: center;
      border-radius: 50%;
      border: 1px solid $blue;
      color: $blue;
      cursor: pointer;
    }
  }
}
</style>